<%@page import="com.neiquan.backstage.user.UserService"%>
<%@page import="com.neiquan.backstage.common.util.SpringContextUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="com.neiquan.backstage.pub.bsc.dao.po.User"%>
<%@page import="com.neiquan.backstage.common.util.Sessions"%>
<%@page import="java.util.List"%>
<%@page import="com.neiquan.backstage.common.CommonService"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
User user = (User) Sessions.getLoginedUser(session);
ApplicationContext appCtx = SpringContextUtils.getApplicationContext();
UserService userService = appCtx.getBean(UserService.class);
pageContext.setAttribute("user", userService.queryById(user.getUserId()));
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta charset="UTF-8">
	<title>我的信息</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1.0" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<link rel="stylesheet" href="css/base.css" />
	<link rel="stylesheet" href="css/main.css" />
</head>
<body bgcolor="#f0f0f0">
		<section class="mt activesignup">
			<section class="tc">
				<form class="fom">
					<section class="common_bg mt">
						<section class="perfect pd">
							<p class="form-inpt-p">
								<label>姓名</label><input class="inpt" name="name" value="${pageScope.user.name}" type="text" placeholder="请输入您的真实姓名" />
							</p>
							<!-- 
							<p class="form-inpt-p">
								<label>公司名称</label><input class="inpt" name="entrepreneurName" value="${pageScope.user.entrepreneurName}" type="text" placeholder="请输入您的公司全称" />
							</p>
							 -->
							<p class="form-inpt-p">
								<label>部门</label><input class="inpt" name="department"  value="${pageScope.user.department}" type="text" placeholder="请输入您的所在部门" />
							</p>
							<p class="form-inpt-p">
								<label>职位</label><input class="inpt" name="post" value="${pageScope.user.post}" type="text" placeholder="请输入您的职位" />
							</p>
							<p class="form-inpt-p">
								<label>手机号</label><input class="inpt" name="phone" value="${pageScope.user.phone}" type="tel" placeholder="请输入您的手机号码" />
							</p>
							<p class="form-inpt-p">
								<label>密码</label><input class="inpt pwd" name="password" value="${pageScope.user.password}" type="password" placeholder="6-20个数字或者字母" />
								<input name="userId"  value="${pageScope.user.userId}" type="hidden" />
							</p>
						</section>
					</section>
					<input class="btn fom-submit" onclick="submitForm()" type="button" value="确 定">
				</form>
			</section>
		</section>
</body>
<script src="js/jquery.min.js"></script>
<script src="js/responsive.js"></script>
<script type="text/javascript">
	function submitForm() {
		var param = {
			"userId": "${pageScope.user.userId}",
			"name": $("input[name='name']").val(),
			"entrepreneurName": $("input[name='entrepreneurName']").val(),
			"department": $("input[name='department']").val(),
			"post": $("input[name='post']").val(),
			"phone": $("input[name='phone']").val(),
			"password": $("input[name='password']").val()
		};
		$.post("api/user/editMyInfo", param, function(data) {
			if(data.code!=0){
				alert(data.errorMessage);
				return;
			}
			alert("修改成功");
			window.location.href="myworkaddr.jsp";
		}); 
	}
	</script>
</html>
